# ============================================================== # It is recommended to test the script on a local machine for its purpose and effects. # ManageEngine Desktop Central will not be responsible for any # damage/loss to the data/setup based on the behavior of the script. # Description: Script to reset Mozilla Firefox (clears 'cache','cache2\entries','thumbnails','cookies.sqlite','webappsstore.sqlite','chromeappstore.sqlite') for a specific user # Parameters: # Remarks: # The script has to be deployed as User Configuration # The Script will kill the Browser, if running # Configuration Type - User # ============================================================== Function Remove-CacheFiles { param([Parameter(Mandatory=$true)][string]$path) BEGIN { $originalVerbosePreference = $VerbosePreference $VerbosePreference = 'Continue' } PROCESS { if((Test-Path $path)) { if([System.IO.Directory]::Exists($path)) { try { if($path[-1] -eq '\') { [int]$pathSubString = $path.ToCharArray().Count - 1 $sanitizedPath = $path.SubString(0, $pathSubString) Remove-Item -Path "$sanitizedPath\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose } else { Remove-Item -Path "$path\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose } } catch { } } else { try { Remove-Item -Path $path -Force -ErrorAction SilentlyContinue -Verbose } catch { } } } } END { $VerbosePreference = $originalVerbosePreference } } Function Clear-FirefoxCacheFiles { param([string]$user=$env:USERNAME) # Kill Firefox if it's running Stop-Process -Name firefox -Force if((Test-Path "C:\users\$user\AppData\Local\Mozilla\Firefox\Profiles")) { $possibleCachePaths = @('cache','cache2\entries','thumbnails','cookies.sqlite','webappsstore.sqlite','chromeappstore.sqlite') $firefoxAppDataPath = (Get-ChildItem "C:\users\$user\AppData\Local\Mozilla\Firefox\Profiles" | Where-Object { $_.Name -match 'Default' }[0]).FullName ForEach($cachePath in $possibleCachePaths) { Remove-CacheFiles "$firefoxAppDataPath\$cachePath" } } } Clear-FirefoxCacheFiles